﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;

namespace CSharpKeyCode
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_KeyDown(object sender, KeyEventArgs e)
        {
            textBoxKeyDown.Text = string.Format("KeyCode:{0}\r\nKeyData:{1}\r\nKeyValue:{2}\r\nAlt:{3}\r\nControl:{4}\r\nShift:{5}\r\nModifiers:{6}\r\n\r\nTime:{7}"
                , e.KeyCode, e.KeyData, e.KeyValue, e.Alt, e.Control, e.Shift, e.Modifiers, DateTime.Now.ToString("FF.fffffff"));
        }

        private void FormMain_KeyPress(object sender, KeyPressEventArgs e)
        {
            textBoxKeyPress.Text = string.Format("KeyChar:{0}\r\nValue:{1}、0x{2}\r\n\r\nTime:{3}", e.KeyChar, (int)e.KeyChar,((int)e.KeyChar).ToString("X2"), DateTime.Now.ToString("FF.fffffff"));
        }

        private void FormMain_KeyUp(object sender, KeyEventArgs e)
        {
            textBoxKeyUp.Text = string.Format("KeyCode:{0}\r\nKeyData:{1}\r\nKeyValue:{2}\r\nAlt:{3}\r\nControl:{4}\r\nShift:{5}\r\nModifiers:{6}\r\n\r\nTime:{7}"
    , e.KeyCode, e.KeyData, e.KeyValue, e.Alt, e.Control, e.Shift, e.Modifiers, DateTime.Now.ToString("FF.fffffff"));
        }

        private void btnASCIITable_Click(object sender, EventArgs e)
        {
            using (FormASCII oForm = new FormASCII())
            {
                oForm.ShowDialog(this);
            }
        }
    }
}
